// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright © 2019 Ariadne Devos

#include <stddef.h>
#include <sHT/index.h>
#include <sHT/string.h>
#include <sHT/test.h>

size_t
sHT_memeq(const char *buffer0, const char *buffer1, size_t correct, size_t otherwise, size_t length)
{
	size_t i;
	/* TODO: optimise -- but without Spectre issues
	   Perhaps do a word at a time. */
	sHT_index_iterate(i, length) {
		/* @var{sHT_and_none} is incorrect here! Strings can contain NUL. */
		if (sHT_neq(buffer0[i], buffer1[i]))
			return otherwise;
	}
	return correct;
}
